home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------
-
- msdos.c
-
- MSDOS-specific routines for use with Info-ZIP's UnZip 5.1 and later.
-
- ---------------------------------------------------------------------------*/
-
-
- #include "unzip.h"
-
- #ifdef __GO32__
- void _dos_setftime(int, unsigned short, unsigned short);
- void _dos_setfileattr(char *, int);
- #endif
-
-
-
- /**********************/
- /* Function mapattr() */
- /**********************/
-
- int mapattr()
- {
- /* set archive bit (file is not backed up): */
- pInfo->file_attr = (unsigned)crec.external_file_attributes | 32;
- return 0;
-
- } /* end function mapattr() */
-
-
-
-
-
- /**************************************/
- /* Function set_file_time_and_close() */
- /**************************************/
-
- void set_file_time_and_close()
- /*
- * MS-DOS VERSION
- *
- * Set the output file date/time stamp according to information from the
- * zipfile directory record for this member, then close the file and set
- * its permissions (archive, hidden, read-only, system). Aside from closing
- * the file, this routine is optional (but most compilers support it).
- */
- {
- #ifdef __TURBOC__
- union {
- struct ftime ft; /* system file time record */
- struct {
- ush ztime; /* date and time words */
- ush zdate; /* .. same format as in .ZIP file */
- } zt;
- } td;
- #endif
-
-
- /*---------------------------------------------------------------------------
- Do not attempt to set the time stamp on standard output.
- ---------------------------------------------------------------------------*/
-
- if (cflag) {
- close(outfd);
- return;
- }
-
- /*---------------------------------------------------------------------------
- Copy and/or convert time and date variables, if necessary; then set the
- file time/date.
- ---------------------------------------------------------------------------*/
-
- #ifdef __TURBOC__
- td.zt.ztime = lrec.last_mod_file_time;
- td.zt.zdate = lrec.last_mod_file_date;
- setftime(outfd, &td.ft);
- #else /* !__TURBOC__ */
- _dos_setftime(outfd, lrec.last_mod_file_date, lrec.last_mod_file_time);
- #endif /* ?__TURBOC__ */
-
- /*---------------------------------------------------------------------------
- And finally we can close the file...at least everybody agrees on how to
- do *this*. I think... Oh yeah, also change the mode according to the
- stored file attributes, since we didn't do that when we opened the dude.
- ---------------------------------------------------------------------------*/
-
- close(outfd);
-
- #ifdef __TURBOC__
- if (_chmod(filename, 1, pInfo->file_attr) != pInfo->file_attr)
- fprintf(stderr, "\nwarning: file attributes may not be correct\n");
- #else
- _dos_setfileattr(filename, pInfo->file_attr);
- #endif
-
- } /* end function set_file_time_and_close() */
-
-
-
-
-
- #ifdef __GO32__
-
- void _dos_setftime(int fd, ush dosdate, ush dostime)
- {
- asm("pushl %ebx");
- asm("movl %0, %%ebx": : "g" (fd));
- asm("movl %0, %%ecx": : "g" (dostime));
- asm("movl %0, %%edx": : "g" (dosdate));
- asm("movl $0x5701, %eax");
- asm("int $0x21");
- asm("popl %ebx");
- }
-
- void _dos_setfileattr(char *name, int attr)
- {
- asm("movl %0, %%edx": : "g" (name));
- asm("movl %0, %%ecx": : "g" (attr));
- asm("movl $0x4301, %eax");
- asm("int $0x21");
- }
-
- #endif /* __GO32__ */
-